﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Templete.master" AutoEventWireup="true"
ValidateRequest="false" EnableViewState="false" EnableEventValidation="false" EnableViewStateMac="false"

  CodeFile="ThirdPartyPersonEdit.aspx.cs" Inherits="ThirdPartyPersonEdit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
          $(document).ready(function () {

              /* setup navigation, content boxes, etc... */
              Administry.setup();
              /* progress bar animations - setting initial values */
	          Administry.progress("#progress1", 1, 6);

              // validate form on keyup and submit
              var validator = $("#aspnetForm").validate({
                  rules: {
                      <%# txtName.UniqueID %>: {
                          required: true,
                          maxlength: 20
                      },
                      <%# txtCode.UniqueID %>: {
                          required: true,
                          maxlength: 20
                      },
                     <%# txtMail.UniqueID %>: {
                         
                          email: true
                      },
                      <%# ddlSex.Name %>: "required"
                  },
                  messages: {
                       <%# txtName.UniqueID %>: "姓名不能为空",
                       <%# txtCode.UniqueID %>: "请输入编号",
                       <%# txtMail.UniqueID %>:"请输入正确的邮箱地址!",
                       <%# ddlSex.Name %>: "请选择性别"

                  },
                  // the errorPlacement has to take the layout into account
                  errorPlacement: function (error, element) {
                      error.insertAfter(element.parent().find('label:first'));
                  },
                  //specifying a submitHandler prevents the default submit, good for the demo
		        submitHandler: function() {
            var data = { 
                txtName: $('#<%# txtName.ClientID %>').val(),
                txtCode: $('#<%# txtCode.ClientID %>').val(),
                txtIdentity: $('#<%# txtIdentity.ClientID %>').val(),
                txtTelephone: $('#<%# txtTelephone.ClientID %>').val(),
                txtMail: $('#<%# txtMail.ClientID %>').val(),
                txtFax: $('#<%# txtFax.ClientID %>').val(),
                ddlPosition: $('#<%# ddlPosition.ClientID %>').val(),
                txtJoinDate: $('#<%# txtJoinDate.ClientID %>').val(),
                ddlSex: $('#<%# ddlSex.ClientID %>').val(),
                chkValid: $('#<%# chkValid.ClientID %>').val(),
                ddlManager:$('#<%# ddlManager.ClientID %>').val()
                }; 
                //提交数据给Login.ashx页面处理 
//                $.post("<%# PostURL %>",data,function(result){
//                 alert(result);
//                }
//                );
                 $.post("<%# PostURL %>",data,function(data){
                  if(data.result=="success"){
                  
                     window.location.replace("ThirdPartyPersonList.aspx?"+data.id);
                  }
                },"json"
                );
               
		    },

                
                  // set new class to error-labels to indicate valid fields
                  success: function (label) {
                      // set &nbsp; as text for IE
                      label.html("&nbsp;").addClass("ok");
                  }
              });

             

          });
    </script>
    
    <fieldset>
        <legend>第三方人员资料维护</legend>
        <p>
            <label class="required" for=" <%# txtName.UniqueID %>">
                姓名:</label><br />
            <input type="text" runat="server" id="txtName" class="half" value="" maxlength="20" />
        </p>
        <p>
            <label class="required" for="<%# txtCode.UniqueID %>">
                编号</label><br />
            <input type="text" runat="server" id="txtCode" class="half" value="" />
        </p>
        <p>
            <label>
                身份证:</label><br />
            <asp:TextBox ID="txtIdentity" class="half" runat="server" MaxLength="18"></asp:TextBox>
            <br />
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtIdentity"
                ErrorMessage="号码格式错误!" SetFocusOnError="True" ValidationExpression="(^\d{15}$)|(\d{17}(?:\d|x|X)$)"
                Font-Bold="True" Display="Dynamic"></asp:RegularExpressionValidator>
        </p>
        <p>
            <label>
                电话号码:</label><br />
            <input id="txtTelephone" type="text" class="default" runat="server" maxlength="20" />
            <br />
            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtTelephone"
                Display="Dynamic" ErrorMessage="电话号码格式错误!" Font-Bold="True" SetFocusOnError="True"
                ValidationExpression="(^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$)|(^((\(\d{3}\))|(\d{3}\-))?(1[358]\d{9})$)"></asp:RegularExpressionValidator>
        </p>
        <p>
            <label for="txtMail">
                电子邮件:</label><br />
            <input type="text" runat="server" id="txtMail" maxlength="40" class="half" />
        </p>
        <p>
            <label>
                传真:</label><br />
            <input type="text" runat="server" id="txtFax" maxlength="40" class="half" />
        </p>
        <p>
            <label class="required" for="<%# ddlPosition.UniqueID %>">
                职位:</label><br />
            <asp:DropDownList ID="ddlPosition" runat="server" DataTextField="Name" DataValueField="DictionaryItemID"
                Width="150px">
            </asp:DropDownList>
            <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="ddlPosition"
                CssClass="required" ErrorMessage="请选择职位" Font-Bold="True" Operator="NotEqual"
                ValueToCompare="--请选择--" Display="Dynamic" />
        </p>
        <p>
            <label>
                入职时间:</label><br />
            <input id="txtJoinDate" type="text" class="Wdate" runat="server" onfocus="WdatePicker();" /><br />
            <asp:RangeValidator ID="rv1" runat="server" ControlToValidate="txtJoinDate" Display="Dynamic"
                ErrorMessage="入职时间不能大于当前时间!" Font-Bold="True" Type="Date"></asp:RangeValidator>
        </p>
        <p>
            <label>
                主管:</label><br />
            <asp:DropDownList ID="ddlManager" runat="server" >
            </asp:DropDownList>
        </p>
        <p>
            <label class="required" for="<%# ddlSex.UniqueID %>">
                性别:</label><br />
            <select id="ddlSex" runat="server" name="<%# ddlSex.UniqueID %>">
                <option value="0">男</option>
                <option value="1">女</option>
            </select>
        </p>
        <p>
            <input type="checkbox" id="chkValid" runat="server" checked />
            <label class="choice" for="chkValid">
                有效</label>
        </p>
    </fieldset>
    <p class="box">
        <asp:Button ID="btnSave" runat="server" class="btn btn-green" Text="提  交" OnClick="btnSave_Click" />
        <a runat="server" id="btnCancel" class="btn"><span class="icon icon-cancel">&nbsp;</span>返
            回</a>
    </p>
</asp:Content>
